 var app_base_url_submit="http://localhost/onlineresult/index.php?/";
  //var app_base_url_submit="http://www.techno-bd.com/onlineresult/index.php?/";
  
  function DelayFunc()
 {
   document.getElementById("blockDim").style.display="none";
 }
 
 function ShowHideBlock(blockHide, blockShow)
 {
  var browserCheck=(document.all) ? 1 : 0;
	var offSetWidth=0;
	var offSetLeft=0;
	if(browserCheck>0)
	{ 
	  offSetWidth=14;
	  offSetLeft=4;  
	}
	var h=document.getElementById(blockHide).offsetHeight;
	var w=document.getElementById(blockHide).offsetWidth+offSetWidth;
	var element=document.getElementById(blockHide);
	var left=0;var top=0;
	if(element.offsetParent)
	 {
	  while(element)
	  {
	    left+=element.offsetLeft;
		top+=element.offsetTop;
		element=element.offsetParent;
	  }
	 }
	   document.getElementById(blockShow).style.height=h+"px";
	   document.getElementById(blockShow).style.width=w-12+"px";
	   document.getElementById(blockShow).style.zIndex=50001;
	   document.getElementById(blockShow).style.display="block";
	   //document.getElementById(blockHide).style.display="none";
	   var tmp1=document.getElementById(blockShow).style;
	   tmp1.left=left-5+offSetLeft+"px";
	   tmp1.top=top+"px";
	   document.getElementById("imagePosition").style.paddingTop=h/2-25+"px"; 
	
 }
 

  ///////////////////////////////////////////////////////////////////
  /////////////////Submit First Term exam Marks/////////////////////
  /////////////////////////////////////////////////////////////////
    $('#first_term_marsk_submit').submit(function(event){
        event.preventDefault();
        var blockHide="first_term_html";
        var blockShow="blockDim";
        ShowHideBlock(blockHide,blockShow);
    
        var request=$.ajax({
	        type: 'POST',
	        url: app_base_url_submit+'admin/student/update_std_first_term_marks',
	        data: $(this).serialize(),
	        dataType: 'json'
	       });

		request.done(function(data_json) {
			   if(data_json!="")
			   {
                    $("#loading").html(data_json.msg);
                    window.setTimeout("DelayFunc()",2000);
	                $("#exam_detail_html").fadeOut(4000);
                    $("#exam_detail_html").fadeIn(4000);
			   }
		});
		
		request.fail(function(jqXHR, textStatus) {
		    alert( "Request failed: " + textStatus );
		});
      });

   /*
  $('#first_term_marsk_submit').submit(function(event) {
                event.preventDefault();
                $.ajax({
                        type: 'POST',
                        url: app_base_url_submit+'admin/student/update_std_marks_detail',
                        data: $(this).serialize(),
                        dataType: 'json',
                        success: function (data) {
                                $('#exam_detail_html').html(data.msg);
                        }
                });
        });
  */
  
    ///////////////////////////////////////////////////////////////////
    /////////////////Submit Promotion Test exam Marks/////////////////////
    /////////////////////////////////////////////////////////////////
      $('#pro_test_marsk_submit').submit(function(event){
          event.preventDefault();
          var blockHide="pro_test_html";
          var blockShow="blockDim";
          ShowHideBlock(blockHide,blockShow);
      
          var request=$.ajax({
  	        type: 'POST',
  	        url: app_base_url_submit+'admin/student/update_std_pro_test_marks',
  	        data: $(this).serialize(),
  	        dataType: 'json'
  	       });

  		request.done(function(data_json) {
  			   if(data_json!="")
  			   {
                      $("#loading").html(data_json.msg);
                      window.setTimeout("DelayFunc()",2000);
  	                $("#pro_test_html").fadeOut(4000);
                      $("#pro_test_html").fadeIn(4000);
  			   }
  		});
  		
  		request.fail(function(jqXHR, textStatus) {
  		    alert( "Request failed: " + textStatus );
  		});
        });  
///////////////////////////////////////////////////////////////////
      /////////////////Submit Pre-Test exam Marks/////////////////////
      /////////////////////////////////////////////////////////////////
        $('#pre_test_marsk_submit').submit(function(event){
            event.preventDefault();
            var blockHide="pre_test_html";
            var blockShow="blockDim";
            ShowHideBlock(blockHide,blockShow);
        
            var request=$.ajax({
    	        type: 'POST',
    	        url: app_base_url_submit+'admin/student/update_std_pre_test_marks',
    	        data: $(this).serialize(),
    	        dataType: 'json'
    	       });

    		request.done(function(data_json) {
    			   if(data_json!="")
    			   {
                        $("#loading").html(data_json.msg);
                        window.setTimeout("DelayFunc()",2000);
    	                $("#pre_test_html").fadeOut(4000);
                        $("#pre_test_html").fadeIn(4000);
    			   }
    		});
    		
    		request.fail(function(jqXHR, textStatus) {
    		    alert( "Request failed: " + textStatus );
    		});
          }); 
      ///////////////////////////////////////////////////////////////////
      /////////////////Submit Test exam Marks/////////////////////
      /////////////////////////////////////////////////////////////////
        $('#test_exam_marsk_submit').submit(function(event){
            event.preventDefault();
            var blockHide="test_exam_html";
            var blockShow="blockDim";
            ShowHideBlock(blockHide,blockShow);
        
            var request=$.ajax({
    	        type: 'POST',
    	        url: app_base_url_submit+'admin/student/update_std_test_exam_marks',
    	        data: $(this).serialize(),
    	        dataType: 'json'
    	       });

    		request.done(function(data_json) {
    			   if(data_json!="")
    			   {
                        $("#loading").html(data_json.msg);
                        window.setTimeout("DelayFunc()",2000);
    	                $("#test_exam_html").fadeOut(4000);
                        $("#test_exam_html").fadeIn(4000);
    			   }
    		});
    		
    		request.fail(function(jqXHR, textStatus) {
    		    alert( "Request failed: " + textStatus );
    		});
          });  
             
  ///////////////////////////////////////////////////////////////////
  /////////////////Submit Student General Information/////////////////////
  /////////////////////////////////////////////////////////////////
    $('#stdGeneralInfo').submit(function(event){
        event.preventDefault();
        var blockHide="stdGenInfoBlock";
   var blockShow="blockDim";
    ShowHideBlock(blockHide,blockShow);
    
        var request=$.ajax({
	        type: 'POST',
	        url: app_base_url_submit+'admin/student/store_std_general_info',
	        data: $(this).serialize(),
	        dataType: 'json'
	       });

		request.done(function(data_json) {
			   if(data_json!="")
			   {
                            $("#loading").html(data_json.msg);
                             window.setTimeout("DelayFunc()",2000);
	                     $("#exam_detail_html").fadeOut(4000);
                             $("#exam_detail_html").fadeIn(4000);
			   }
		});
		
		request.fail(function(jqXHR, textStatus) {
		    alert( "Request failed: " + textStatus );
		});
      });
     
    ///////////////////////////////////////////////////////////////////
    /////////////////edit Student General Information/////////////////////
    /////////////////////////////////////////////////////////////////
      $('#frm_edit_stdGeneralInfo').submit(function(event){
          event.preventDefault();
          var blockHide="stdGenInfoBlock";
     var blockShow="blockDim";
      ShowHideBlock(blockHide,blockShow);
      
          var request=$.ajax({
  	        type: 'POST',
  	        url: app_base_url_submit+'admin/student/edit_std_general_info',
  	        data: $(this).serialize(),
  	        dataType: 'json'
  	       });

  		request.done(function(data_json) {
  			   if(data_json!="")
  			   {
                      $("#loading").html(data_json.msg);
                      window.setTimeout("DelayFunc()",2000);
  	                  $("#edit_stdGeneralInfo").fadeOut(4000);
                      // $("#exam_detail_html").fadeIn(4000);
  			   }
  		});
  		
  		request.fail(function(jqXHR, textStatus) {
  		    alert( "Request failed: " + textStatus );
  		});
        });
  
      ///////////////////////////////////////////////////////////////////
      /////////////////submit add new subject/////////////////////
      /////////////////////////////////////////////////////////////////
        $('#frm_add_new_subject').submit(function(event){
            event.preventDefault();
            var blockHide="add_new_subject";
       var blockShow="blockDim";
        ShowHideBlock(blockHide,blockShow);
        
            var request=$.ajax({
    	        type: 'POST',
    	        url: app_base_url_submit+'admin/student/store_new_subject',
    	        data: $(this).serialize(),
    	        dataType: 'json'
    	       });

    		request.done(function(data_json) {
    			   if(data_json!="")
    			   {
                        $("#loading").html(data_json.msg);
                        window.setTimeout("DelayFunc()",2000);
    	                  $("#add_new_subject").fadeOut(4000);
                        // $("#add_new_subject").fadeIn(4000);
    			   }
    		});
    		
    		request.fail(function(jqXHR, textStatus) {
    		    alert( "Request failed: " + textStatus );
    		});
          });
            
    ///////////////////////////////////////////////////////////////////
    /////////////////Submit optional Subject assing/////////////////////
    /////////////////////////////////////////////////////////////////
      $('#opt_sub_form').submit(function(event){
          event.preventDefault();
          var blockHide="opt_subject_html";
          var blockShow="blockDim";
         ShowHideBlock(blockHide,blockShow);
      
          var request=$.ajax({
  	        type: 'POST',
  	        url: app_base_url_submit+'admin/student/store_std_optional_or_core_subject',
  	        data: $(this).serialize(),
  	        dataType: 'json'
  	       });

  		request.done(function(data_json) {
  			   if(data_json!="")
  			   {
                   $("#loading").html(data_json.msg);
                   window.setTimeout("DelayFunc()",2000);
  	               //$("#opt_subject_html").fadeOut(4000);
  			   }
  		});
  		
  		request.fail(function(jqXHR, textStatus) {
  		    alert( "Request failed: " + textStatus );
  		});
        });
      
      
      ///////////////////////////////////////////////////////////////////
      /////////////////Submit optional Subject assing/////////////////////
      /////////////////////////////////////////////////////////////////
        $('#subj_total_att_form').submit(function(event){
            event.preventDefault();
            var blockHide="subj_total_att_html";
            var blockShow="blockDim";
           ShowHideBlock(blockHide,blockShow);
        
            var request=$.ajax({
    	        type: 'POST',
    	        url: app_base_url_submit+'admin/student/subject_total_attendence_store',
    	        data: $(this).serialize(),
    	        dataType: 'json'
    	       });

    		request.done(function(data_json) {
    			   if(data_json!="")
    			   {
                     $("#loading").html(data_json.msg);
                     window.setTimeout("DelayFunc()",2000);
    	               //$("#opt_subject_html").fadeOut(4000);
    			   }
    		});
    		
    		request.fail(function(jqXHR, textStatus) {
    		    alert( "Request failed: " + textStatus );
    		});
          });    
        ///////////////////////////////////////////////////////////////////
        /////////////////Submit individul Student Subjects////////////////
        /////////////////////////////////////////////////////////////////
          $('#std_subject_form').submit(function(event){
              event.preventDefault();
              var blockHide="std_subjects_list";
              var blockShow="blockDim";
             ShowHideBlock(blockHide,blockShow);
          
             
             var theForm = document.getElementById("std_subject_form"); // get the form
             var chk_subjects = theForm.getElementsByTagName('input');  // get the inputs
             for(var i=0;i<chk_subjects.length;i++){ 
            	    if(chk_subjects[i].type=='checkbox' && !chk_subjects[i].checked)  // if this is an unchecked checkbox
            	    {
            	    	chk_subjects[i].value = 0; // set the value to "off"
            	    	chk_subjects[i].checked = true; // make sure it submits
            	    }
            	}

             
             
              var request=$.ajax({
      	        type: 'POST',
      	        url: app_base_url_submit+'admin/student/assign_std_subjects',
      	        data: $(this).serialize(),
      	        dataType: 'json'
      	       });

      		request.done(function(data_json) {
      			   if(data_json!="")
      			   {
                       $("#loading").html(data_json.msg);
                       window.setTimeout("DelayFunc()",2000);
                       //$("#std_subjects_list").fadeOut(4000);
                       show_subjects();
      			   }
      		});
      		
      		request.fail(function(jqXHR, textStatus) {
      		    alert( "Request failed: " + textStatus );
      		});
            });    
                    
          ///////////////////////////////////////////////////////////////////
          /////////////////Submit Subject total marks exam/////////////////////
          /////////////////////////////////////////////////////////////////
            $('#subj_total_exam_marsk_submit').submit(function(event){
                event.preventDefault();
                var blockHide="subj_total_exam_marsk_html";
                var blockShow="blockDim";
               ShowHideBlock(blockHide,blockShow);
            
                var request=$.ajax({
        	        type: 'POST',
        	        url: app_base_url_submit+'admin/student/update_total_exam_marks',
        	        data: $(this).serialize(),
        	        dataType: 'json'
        	       });

        		request.done(function(data_json) {
        			   if(data_json!="")
        			   {
                         $("#loading").html(data_json.msg);
                         window.setTimeout("DelayFunc()",2000);
        	               //$("#opt_subject_html").fadeOut(4000);
        			   }
        		});
        		
        		request.fail(function(jqXHR, textStatus) {
        		    alert( "Request failed: " + textStatus );
        		});
              });       